package puzzle.masyu2.loader;

import puzzle.common.loader.AbstractLoader;
import puzzle.common.loader.Preprocessor;
import puzzle.masyu2.data.DangoType;
import puzzle.masyu2.data.MasyuBoard;

public class MasyuLoader extends AbstractLoader<MasyuBoard> {
	public MasyuBoard process(Preprocessor pp) {
		MasyuBoard b = new MasyuBoard(pp.getWidth(), pp.getHeight());
		for (int y = 0; y < b.height; y++) {
			String[] fields = pp.getLines().get(y);
			for (int x = 0; x < b.width; x++) {
				DangoType dt;
				switch (fields[x].charAt(0)) {
				case '1':
					dt = DangoType.SHIRO;
					break;
				case '2':
					dt = DangoType.KURO;
					break;
				default:
					dt = DangoType.NONE;
					break;
				}
				b.setDangoType(x, y, dt);
			}
		}
		return b;
	}

}
